#! /usr/bin/env perl

use strict;
use warnings;

use VCtools::Base;
use VCtools::Args;
use VCtools::Common;


#################################
# OPTIONS AND ENVIRONMENT VARS
#################################

VCtools::switch('recursive', 'r', 'operate recursively');
VCtools::args('files', 'optlist', 'file(s) (or directory/ies) to synchronize with repository');
VCtools::getopts();

# remember, directories are files too
my @files = VCtools::files();
@files = (".") unless @files;
print STDERR "status for files: @files\n" if DEBUG >= 3;


#################################
# CHECK FOR ERRORS
#################################

VCtools::verify_files_and_group(@files);

# get statuses for everything at once (quicker that way)
VCtools::cache_file_status(@files);

foreach my $file (@files)
{
	VCtools::fatal_error("$file is not in VC") unless VCtools::exists_in_vc($file);
}


#################################
# MAIN
#################################

VCtools::update_files(@files);

print "done\n" unless $?;


#################################
# SUBS
#################################
